package com.apes.scm.masterdata.party.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.DateUtil;
import com.apes.hr.base.model.SkillLevel;
import com.apes.hr.base.model.SkillType;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * 功能：当事人技能证书
 *
 * @author xul
 * @create 2018-01-23 11:11
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = PersonSkillCertificate.CONST_TABLE_NAME)
public class PersonSkillCertificate  extends Model {
    public static final String CONST_TABLE_NAME = "mas_person_skill_certificate";

    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "当事人")
    private long id;   //技能证书内码

    @Name
    @Column(name = "cert_number", nullable = false, length = 32)
    private String certNumber; //技能证书号码

    @ManyToOne(optional = false)
    @JoinColumn(name="PARTY_ID", referencedColumnName="ID", nullable = false)
    private PartyRole party;  //当事人

    @ManyToOne(optional = false)
    @JoinColumn(name="skill_type_ID", referencedColumnName="ID", nullable = false)
    private SkillType skillType;  //技能证书类型

    @ManyToOne(optional = false)
    @JoinColumn(name="skill_level_ID", referencedColumnName="ID", nullable = false)
    private SkillLevel skillLevel;  //技能证书等级

    @Column(name = "issuing_organ", length = 50)
    private String issuingOrgan; //发证机关

    @Column(name = "qualification", length = 50)
    private String qualification;  //熟练程度

    @Column(name = "DESCRIPTION", length = 80)
    private String description; //说明

    @JSONField(format = DateUtil.SHOW_DATE_FORMAT)
    @Temporal(TemporalType.DATE)
    @Column(name = "issuing_date", nullable = false)
    private Date issuingDate; //颁发日期

    @Column(name = "effective_age", nullable = false, columnDefinition = "number(8,0) default 0")
    private int effectiveAge = 0; //有效年限

    @Column(name = "is_record", nullable = false, columnDefinition = "number(1,0) default 0")
    private boolean isRecord = false; //是否备案

}
